<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>变量</title>
</head>
<body>
<script>
    /**
     * 通过构造函数创建对象
     *  什么是构造函数？
     *      new 关键字创建对象
     */

    function Persion(name,age,gender){
        this.name=name;
        this.age=age;
        this.gender=gender;
        this.sayName = function(){
            alert("我的名字是："+this.name)
        }
    }

    function Dog(name,age,gender){
        this.name=name;
        this.age=age;
        this.gender=gender;
        this.sayName = function(){
            alert("我的名字是："+this.name)
        }
    }

    var persion = new Persion("张三",18,"男");
    var persion1 = new Persion("李四",18,"男");

    console.log(persion)
    console.log(persion1)

    console.log(persion instanceof Persion) //检查对象是否是某个构造函数创建的



    var dog = new Dog("小黄",18,"男");
    var dog1 = new Dog("小黑",18,"男");
    console.log(dog)
    console.log(dog1)
    console.log(dog instanceof Dog)

    console.log(dog instanceof Object)
    console.log(persion instanceof Object)
</script>
</body>
</html>
